package com.yuncheng.spcyApi.spcy;

import cn.hutool.core.collection.CollectionUtil;
import com.yuncheng.spcyApi.alog.annotation.Log;
import com.yuncheng.spcyApi.alog.utils.StringEmptyUtils;
import com.yuncheng.spcyApi.constant.common.LogConstant;
import com.yuncheng.spcyApi.constant.common.SpcyConstant;
import com.yuncheng.spcyApi.entity.*;
import com.yuncheng.exception.BusinessException;
import com.yuncheng.entity.YcSysUser;
import com.yuncheng.spcyApi.service.*;
import com.yuncheng.spcyApi.spcyService.JcyLxpgdjbService;
import com.yuncheng.spcyApi.spcyService.SpcyJcyLxService;
import com.yuncheng.spcyApi.spcyService.SpcyMyInfoService;
import com.yuncheng.spcyApi.spcyService.ZdyUploadFileService;
import com.yuncheng.spcyApi.utils.GetUuIdUtils;
import com.yuncheng.spcyApi.vo.common.HttpResultVo;
import com.yuncheng.spcyApi.vo.common.OrderItemVo;
import com.yuncheng.spcyApi.vo.jcy.JcyLxUserVo;
import com.yuncheng.spcyApi.vo.spcy.ZcTreeVo;
import com.yuncheng.vo.HttpResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import utils.DateConversionUtils;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.security.NoSuchAlgorithmException;
import java.security.spec.InvalidKeySpecException;
import java.util.*;
import java.util.stream.Collectors;


/**
 * @author hua
 */
@Api(tags = "检查员遴选-登记采集相关信息")
@RestController
@RequestMapping("/api/spzx-spcy/jcylxdjcj")
public class JcyLxdjcjController {

    @Resource
    private SpcyJcyLxService spcyJcyLxService;

    @Resource
    private JcyLxpgdjbService jcyLxpgdjbService;

    /*@Resource
    private ISpcyJcyLxqdcsService spcyJcyLxqdcsService;*/

    @Resource
    private ISpcyRsZckService spcyRsZckService;

    @Resource
    private ISysUserFbwzService sysUserFbwzService;

    @Resource
    private ISysUserGzjlService sysUserGzjlService;

    @Resource
    private ISysUserPxjlService sysUserPxjlService;

    @Resource
    private IYcSysUserService sysUserService;

    @Resource
    private ISpcyRsDwkService spcyRsDwkService;

    @Resource
    private ZdyUploadFileService zdyUploadFileService;

    @Resource
    private SpcyMyInfoService spcyMyInfoService;


    @Log(title = "新增文章")
    @ApiOperation(value = "新增文章")
    @GetMapping(value = "addDjwz")
    public HttpResult addDjwz(@RequestParam(value = "id",defaultValue = "") String id){
        if (StringEmptyUtils.isBlank(id)){
            throw new BusinessException("参数为空！");
        }
        SysUserFbwz newWz = new SysUserFbwz();
        newWz.setFuserid(id);
        SysUserFbwz fbwz = sysUserFbwzService.addFbwz(newWz);

        return HttpResult.ok(fbwz);
    }

    @Log(title = "新增工作经历")
    @ApiOperation(value = "新增工作经历")
    @GetMapping(value = "addDjgzjl")
    public HttpResult addDjgzjl(@RequestParam(value = "id",defaultValue = "") String id){
        if (StringEmptyUtils.isBlank(id)){
            throw new BusinessException("参数为空！");
        }
        SysUserGzjl newgzjl = new SysUserGzjl();
        newgzjl.setFuserid(id);
        YcSysUser user = sysUserService.getById(id);
        if (user != null) {
            newgzjl.setFusermc(user.getRealname());
        }
        SysUserGzjl gzjl = sysUserGzjlService.addGzjl(newgzjl);
        return HttpResult.ok(gzjl);
    }

    @Log(title = "新增培训记录")
    @ApiOperation(value = "新增培训记录")
    @GetMapping(value = "addPxjl")
    public HttpResult addPxjl(@RequestParam(value = "id",defaultValue = "") String id){
        if (StringEmptyUtils.isBlank(id)){
            throw new BusinessException("参数为空！");
        }
        SysUserPxjl newPxjl = new SysUserPxjl();
        newPxjl.setFuserid(id);
        SysUserPxjl pxjl = sysUserPxjlService.addPxjl(newPxjl);

        return HttpResult.ok(pxjl);
    }

    @Log(title = "更新检查员登记表")
    @ApiOperation(value = "更新检查员登记表")
    @PutMapping(value = "updateJcydjb")
    public HttpResult updateJcydjb(@RequestBody HashMap<String, String> buffer) throws InvocationTargetException, IllegalAccessException {
        sysUserService.updateSysUser(buffer);

        SpcyPxCjry cjry = new SpcyPxCjry();
        BeanUtils.populate(cjry, buffer);
        if (StringEmptyUtils.isNotBlank(cjry.getFdwyj())){
            SpcyJcyRzlb rzlb = new SpcyJcyRzlb();
            BeanUtils.populate(rzlb, buffer);

            if (StringEmptyUtils.isBlank(rzlb.getId())){
                throw new BusinessException("参数为空！");
            }
            if (StringEmptyUtils.isBlank(rzlb.getFlxjhid())){
                throw new BusinessException("遴选参数为空！");
            }
//            String id = buffer.get("id");
//            String flxjhid = buffer.get("flxjhid");

            spcyJcyLxService.updateCjryInfo(rzlb.getId(), rzlb.getFlxjhid(), cjry.getFdwyj());
        }

        return HttpResult.ok("保存成功");
    }

    @Log(title = "更新发表文章-根据文章id")
    @ApiOperation(value = "更新发表文章-根据文章id")
    @PutMapping(value = "updateWz")
    public HttpResult updateWz(@RequestBody SysUserFbwz buffer) throws InvocationTargetException, IllegalAccessException, NoSuchMethodException {

        sysUserFbwzService.updatwFbwzById(buffer);
        return HttpResult.ok("保存成功");
    }

    @Log(title = "更新工作经历-根据工作经历id")
    @ApiOperation(value = "更新工作经历-根据工作经历id")
    @PutMapping(value = "updateGzjl")
    public HttpResult updateGzjl(@RequestBody HashMap<String, String> buffer) throws InvocationTargetException, IllegalAccessException {

        sysUserGzjlService.updateGzjl(buffer);
        return HttpResult.ok("保存成功");
    }

    @Log(title = "更新培训记录-根据培训记录id")
    @ApiOperation(value = "更新培训记录-根据培训记录id")
    @PutMapping(value = "updatePxjl")
    public HttpResult updatePxjl(@RequestBody SysUserPxjl buffer) throws InvocationTargetException, IllegalAccessException, NoSuchMethodException {

        sysUserPxjlService.updatePxjl(buffer);
        return HttpResult.ok("保存成功");
    }

    @Log(title = "更新检查员类别-根据类别id")
    @ApiOperation(value = "更新检查员类别-根据类别id")
    @PutMapping(value = "updateLb")
    public HttpResult updateLb(@RequestBody HashMap<String, String> buffer) throws InvocationTargetException, IllegalAccessException {

        spcyJcyLxService.updateLb(buffer);
        return HttpResult.ok("保存成功");
    }

    @Log(title = "删除发表文章-根据文章id")
    @ApiOperation(value = "删除发表文章-根据文章id")
    @DeleteMapping(value = "deleteWz")
    public HttpResult deleteWz(@RequestParam(value = "id",defaultValue = "") String id){
        sysUserFbwzService.removeById(id);

        return HttpResult.ok("删除成功");
    }

    @Log(title = "删除工作经历-根据工作经历id")
    @ApiOperation(value = "删除工作经历-根据工作经历id")
    @DeleteMapping(value = "deleteGzjl")
    public HttpResult deleteGzjl(@RequestParam(value = "id",defaultValue = "") String id){

        sysUserGzjlService.removeById(id);
        return HttpResult.ok("删除成功");
    }

    @Log(title = "根据身份证号获取手机号")
    @ApiOperation(value = "根据身份证号获取手机号")
    @GetMapping(value = "getPhoneBySfzh")
    public HttpResult getPhoneBySfzh(@RequestParam(value = "fsfzh",defaultValue = "") String fsfzh){

        String phone = "";

        List<YcSysUser> sysUserList = sysUserService.selectUserBySfzh(fsfzh);
        if (CollectionUtil.isNotEmpty(sysUserList)){
            phone = sysUserList.get(0).getPhone();
        }

        HttpResult result = new HttpResult(true);
        result.setResult(phone);
        result.setMessage("获取成功");
        return result;
    }

    @Log(title = "发送验证码")
    @ApiOperation(value = "发送验证码")
    @GetMapping(value = "sendYzm")
    public HttpResult sendYzm(@RequestParam(value = "fsfzh",defaultValue = "") String fsfzh,
                              @RequestParam(value = "phone",defaultValue = "") String phone,
                              @RequestParam(value = "flxjhid",defaultValue = "")String flxjhid) throws NoSuchAlgorithmException, IOException, InvalidKeySpecException {
        if (StringEmptyUtils.isBlank(flxjhid)){
            throw new BusinessException("参数为空！");
        }
        spcyJcyLxService.sendYzm(fsfzh,phone,flxjhid);
        return HttpResult.ok("发送成功");
    }

    @Log(title = "身份证验证重载-并加载遴选登记信息")
    @ApiOperation(value = "身份证验证重载-并加载遴选登记信息")
    @GetMapping(value = "verifyJcydjb")
    public HttpResult verifyJcydjb(@RequestParam(value = "fsfzh",defaultValue = "") String fsfzh,
                                   @RequestParam(value = "flxjhid",defaultValue = "")String flxjhid){
        /*if (org.apache.commons.lang3.StringUtils.isBlank(code)){
            return HttpResult.error("请输入验证码！");
        }*/
        if (org.apache.commons.lang3.StringUtils.isBlank(flxjhid)){
            return HttpResult.error("参数为空！");
        }
        Map map = spcyJcyLxService.initReloadJcydjb(fsfzh, null, "3781", flxjhid);

        return HttpResult.ok(map);
    }

    @Log(title = "查询-检查员登记表-根据登记表id")
    @ApiOperation(value = "查询-检查员登记表-根据登记表id")
    @GetMapping(value = "queryDjbById")
    public HttpResult queryDjbById(@RequestParam(value = "id",defaultValue = "") String userid,
                                   @RequestParam(value = "flxjhid",defaultValue = "")String flxjhid){
        if (org.apache.commons.lang3.StringUtils.isBlank(flxjhid)){
            return HttpResult.error("参数为空！");
        }
        if (org.apache.commons.lang3.StringUtils.isBlank(userid)){
            throw new BusinessException("登记表参数为空！");
        }

        Map map = spcyJcyLxService.queryJcydjbInfo(null, null, userid, flxjhid);

        return HttpResult.ok(map);
    }

    @Log(title = "提交-检查员登记表")
    @ApiOperation(value = "提交-检查员登记表")
    @GetMapping(value = "submitJcydjb")
    public HttpResult submitJcydjb(@RequestParam(value = "id",defaultValue = "") String userid,
                                   @RequestParam(value = "flxjhid",defaultValue = "")String flxjhid){

        spcyJcyLxService.submitJcydjb(userid, flxjhid);
        return HttpResult.ok("提交成功");
    }

    @Log(title = "退回填写")
    @ApiOperation(value = "退回填写")
    @PostMapping(value = "updateSjcjzt")
    public HttpResult updateSjcjzt(@RequestBody Map<String,String> paramsBo){
        String ids = paramsBo.get("ids");
        String flxjhid = paramsBo.get("flxjhid");

        spcyJcyLxService.updateSjcjztYtjToTxz(ids, flxjhid);
        return HttpResult.ok("退回成功");
    }

    @ApiOperation(value = "下载检查员推荐表-登记id和遴选id")
    @GetMapping(value = "replateFile")
    public void replateFile(@RequestParam(value = "id",defaultValue = "") String userid,
                            @RequestParam(value = "flxjhid",defaultValue = "")String flxjhid,
                            HttpServletResponse response){
        spcyJcyLxService.downloadDjbFile(userid, flxjhid, response);
    }

    @ApiOperation(value = "下载检查员推荐表-通过遴选人员id")
    @GetMapping(value = "downloadDjbFile")
    public void downloadDjbFile(@RequestParam(value = "id",defaultValue = "") String cjryid, HttpServletResponse response){
        spcyJcyLxService.downloadDjbFile(cjryid, response);
    }

    /** 测试用 */
    @GetMapping(value = "cxxzwj")
    public void cxxzwj(@RequestParam(value = "id",defaultValue = "") String userid,
                            @RequestParam(value = "flxjhid",defaultValue = "")String flxjhid,
                            @RequestParam(value = "templateFlag",defaultValue = "true")boolean templateFlag,
                            HttpServletResponse response){
        spcyJcyLxService.cxxzwj(userid, flxjhid, templateFlag, response);
    }


    @Log(title = "查询遴选计划培训信息")
    @ApiOperation(value = "查询遴选计划培训信息")
    @GetMapping(value = "jhInfoById")
    public HttpResult jhInfoById(@RequestParam(value = "flxjhid",defaultValue = "")String flxjhid,
                                 @RequestParam(value = "id",defaultValue = "") String userid){

        Map resultMap = spcyJcyLxService.jhInfoById(flxjhid, userid);

        String dcbState = "未提交";
        SpcyJcyLxjxpgdcb dcb = jcyLxpgdjbService.getDcbByUserId(flxjhid, userid);
        if (dcb != null && StringUtils.isNotBlank(dcb.getFtjzt())){
            dcbState = dcb.getFtjzt();
        }
        resultMap.put("dcbState", dcbState);
        return HttpResult.ok(resultMap);
    }

    /*@Log(title = "继续教育-考试报名")
    @ApiOperation(value = "继续教育-考试报名")*/
    @GetMapping(value = "jxjyksbm")
    public HttpResult jxjyksbm(@RequestParam(value = "fsfzh",defaultValue = "") String fsfzh,
                               @RequestParam(value = "phone",defaultValue = "") String phone,
                               @RequestParam(value = "flxjhid",defaultValue = "")String flxjhid){

        spcyJcyLxService.jxjyksbm(fsfzh, phone, flxjhid);

        return HttpResult.ok("报名成功");
    }

    @Log(title = "遴选计划-培训签到")
    @ApiOperation(value = "遴选计划-培训签到")
    @GetMapping(value = "lxjhPxqd")
    public HttpResult lxjhPxqd(@RequestParam(value = "flxjhid",defaultValue = "")String flxjhid,
                               @RequestParam(value = "flxqdccid",defaultValue = "")String flxqdccid,
                               @RequestParam(value = "id",defaultValue = "")String userid){

        spcyJcyLxService.lxjhPxqd(flxjhid, userid, flxqdccid);

        return HttpResult.ok("签到成功");
    }

    @Log(title = "遴选计划-培训开始考试")
    @ApiOperation(value = "遴选计划-培训开始考试")
    @GetMapping(value = "lxjhPxksks")
    public HttpResult lxjhPxksks(@RequestParam(value = "flxjhid",defaultValue = "")String flxjhid,
                                 @RequestParam(value = "id",defaultValue = "")String userid){
        if (org.apache.commons.lang3.StringUtils.isBlank(flxjhid)){
            throw new BusinessException("参数为空！");
        }
        if (org.apache.commons.lang3.StringUtils.isBlank(userid)){
            throw new BusinessException("人员为空！");
        }

        Map resultMap = spcyJcyLxService.lxjhPxksks(flxjhid, userid);
        return HttpResult.ok(resultMap);
    }


    @ApiOperation(value = "单位库列表")
    @GetMapping(value = "/dwList")
    public HttpResult<?> dwList(SpcyRsDwk query, OrderItemVo orderItemVo) {

        return HttpResultVo.HttpResultList(spcyRsDwkService.selectList(query,orderItemVo));
    }

    @ApiOperation(value = "技术职称系列库列表")
    @GetMapping(value = "/jszcList")
    public HttpResult<?> jszcList(SpcyRsZck query) {
        List<SpcyRsZck> zcList = spcyRsZckService.selectList(query);

        List<ZcTreeVo> xl1TreeList = new ArrayList<>();

        if (StringEmptyUtils.isBlank(query.getFzcxllx2()) && StringEmptyUtils.isBlank(query.getFzyjszg())) {
            List<String> xl1List = zcList.stream()
                    .map(SpcyRsZck::getFzcxllx1)
                    .distinct()
                    .collect(Collectors.toList());

            xl1List.forEach(e -> {
                if (StringEmptyUtils.isNotBlank(e)) {
                    ZcTreeVo zcTreeVo = new ZcTreeVo();
                    zcTreeVo.setKey(e);
                    zcTreeVo.setTitle(e);
                    zcTreeVo.setId(GetUuIdUtils.ReplaceUuId());

                    List<ZcTreeVo> childrenList = new ArrayList<>();
                    List<SpcyRsZck> zcxl2List = zcList.stream()
                            .filter(f -> StringEmptyUtils.isNotBlank(f.getFzcxllx1()) && f.getFzcxllx1().equals(e))
                            .collect(Collectors.toList());
                    if (CollectionUtil.isNotEmpty(zcxl2List)) {
                        List<String> xl2List = zcxl2List.stream()
                                .map(SpcyRsZck::getFzcxllx2)
                                .distinct()
                                .collect(Collectors.toList());

                        for (String xl2 : xl2List) {
                            ZcTreeVo zcTreeVo2 = new ZcTreeVo();
                            zcTreeVo2.setId(GetUuIdUtils.ReplaceUuId());
                            zcTreeVo2.setKey(xl2);
                            zcTreeVo2.setTitle(xl2);
                            zcTreeVo2.setParentid(zcTreeVo.getId());
                            childrenList.add(zcTreeVo2);
                        }
                    }
                    zcTreeVo.setChildren(childrenList);
                    xl1TreeList.add(zcTreeVo);
                }
            });
        }

        if (StringEmptyUtils.isNotBlank(query.getFzcxllx2()) && StringEmptyUtils.isBlank(query.getFzyjszg())){
            List<String> xl1List = zcList.stream()
                    .map(SpcyRsZck::getFzcxllx2)
                    .distinct()
                    .collect(Collectors.toList());

            xl1List.forEach(e -> {
                List<SpcyRsZck> zcxl2List = zcList.stream()
                        .filter(f -> StringEmptyUtils.isNotBlank(f.getFzcxllx2()) && f.getFzcxllx2().equals(e))
                        .collect(Collectors.toList());

                for (SpcyRsZck zc : zcxl2List) {
                    ZcTreeVo zcTreeVo2 = new ZcTreeVo();
                    zcTreeVo2.setId(zc.getId());
                    zcTreeVo2.setKey(zc.getFzyjszg());
                    zcTreeVo2.setTitle(zc.getFzyjszg());
                    zcTreeVo2.setJb(zc.getFjb());
                    xl1TreeList.add(zcTreeVo2);
                }
            });

        }

        if (StringEmptyUtils.isNotBlank(query.getFzyjszg())){
            List<String> xl1List = zcList.stream()
                    .map(SpcyRsZck::getFzyjszg)
                    .distinct()
                    .collect(Collectors.toList());

            xl1List.forEach(e -> {
                List<SpcyRsZck> zcxl2List = zcList.stream()
                        .filter(f -> StringEmptyUtils.isNotBlank(f.getFzyjszg()) && f.getFzyjszg().equals(e))
                        .collect(Collectors.toList());

                for (SpcyRsZck zc : zcxl2List) {
                    ZcTreeVo zcTreeVo2 = new ZcTreeVo();
                    zcTreeVo2.setId(zc.getId());
                    zcTreeVo2.setKey(zc.getFjb());
                    zcTreeVo2.setTitle(zc.getFjb());
                    zcTreeVo2.setJb(zc.getFjb());
                    xl1TreeList.add(zcTreeVo2);
                }
            });
        }

        return HttpResult.ok(xl1TreeList);
    }

    @Log(title = "上传-用户照片")
    @ApiOperation(value = "上传-用户照片")
    @PostMapping(value = "uploadMyPhoto")
    public HttpResult<?> uploadMyPhoto(@RequestParam("file") MultipartFile file,
                                       @RequestParam(value = "id",defaultValue = "")String id){
        if (StringEmptyUtils.isBlank(id)){
            throw new BusinessException("参数为空！");
        }
        zdyUploadFileService.uploadMyPhoto(file, id);
        return HttpResult.ok("上传成功");
    }

    @Log(title = "上传用户签名")
    @ApiOperation(value = "上传用户签名")
    @PostMapping(value = "uploadMyQm")
    public HttpResult<?> uploadMyQm(@RequestParam("file") MultipartFile file,
                                    @RequestParam(value = "id",defaultValue = "")String id){
        if (StringEmptyUtils.isBlank(id)){
            return HttpResult.error("参数为空！");
        }

        zdyUploadFileService.uploadMyQm(file, id);
        return HttpResult.ok("上传签名成功");
    }

    @Log(title = "获取用户签名照片链接")
    @ApiOperation(value = "获取用户签名照片链接")
    @GetMapping(value = "getUserSignPhotoLink")
    public HttpResult getUserSignPhotoLink(@RequestParam(value = "id",defaultValue = "")String fuserid){
        if (StringEmptyUtils.isBlank(fuserid)){
            return HttpResult.error("参数为空！");
        }

        Map map = spcyMyInfoService.getUserSignPhotoLink(fuserid, true);

        return HttpResult.ok(map);
    }

    @Log(title = "推荐表盖章文件-上传")
    @ApiOperation(value = "推荐表盖章文件-上传")
    @PostMapping(value = "uploadtjbgzFile")
    public HttpResult<?> uploadtjbgzFile(@RequestParam("file") MultipartFile[] file,
                                        @RequestParam(value = "id",defaultValue = "")String id,
                                         @RequestParam(value = "flxjhid",defaultValue = "")String flxjhid){
        if (StringEmptyUtils.isBlank(id)){
            throw new BusinessException("登记表参数为空！");
        }

        if (StringEmptyUtils.isBlank(flxjhid)){
            throw new BusinessException("参数为空！");
        }

        String pid = "";
        SpcyPxCjry cjry = spcyJcyLxService.getUploadtjbgzFile(flxjhid, id);
        if (cjry != null){
            pid = cjry.getId();
        }

        List<SpcySqsxWjjl> wjjlList = zdyUploadFileService.queryWjjlByPid(pid, LogConstant.LOGS_JCY_LXTJBGZWJ);
        if (CollectionUtil.isNotEmpty(wjjlList)){
            for (SpcySqsxWjjl wjjl : wjjlList) {
                zdyUploadFileService.deleteFileRecords(wjjl);
                zdyUploadFileService.deleteFileByUrl(wjjl.getFcflj(), false);
            }
        }

        String originalFilename = file[0].getOriginalFilename();
        // 文件类型
        String wjlx = originalFilename.substring(originalFilename.lastIndexOf("."));

        String wjid = GetUuIdUtils.ReplaceUuId();
        zdyUploadFileService.uploadFile(file, pid, LogConstant.LOGS_JCY_LXTJBGZWJ, SpcyConstant.JCY_LXJH_FILE_BASE_URL+"/"+ DateConversionUtils.DateToYear(new Date()), wjid);

        cjry.setFcfgzwj(wjlx);
        spcyJcyLxService.updateUploadtjbgzFile(cjry, wjlx);

        return HttpResultVo.HttpResultSave(cjry,"上传成功");
    }

    @ApiOperation(value = "推荐表盖章文件-下载")
    @GetMapping(value = "downloadTjbGzFile")
    public void downloadTjbGzFile(@RequestParam(value = "id",defaultValue = "")String id,
                                  @RequestParam(value = "flxjhid",defaultValue = "")String flxjhid,
                                  HttpServletResponse response){

        if (StringEmptyUtils.isBlank(id)){
            throw new BusinessException("登记表参数为空！");
        }

        if (StringEmptyUtils.isBlank(flxjhid)){
            throw new BusinessException("参数为空！");
        }

        String pid = "";
        SpcyPxCjry cjry = spcyJcyLxService.getUploadtjbgzFile(flxjhid, id);
        if (cjry == null){
            throw new BusinessException("没有相匹配的数据！");
        }
        pid = cjry.getId();

        List<SpcySqsxWjjl> wjjlList = zdyUploadFileService.queryWjjlByPid(pid, LogConstant.LOGS_JCY_LXTJBGZWJ);
        if (CollectionUtil.isEmpty(wjjlList)){
            throw new BusinessException("没有相匹配的文件数据!");
        }

        zdyUploadFileService.downloadFile(wjjlList.get(0), false, response);

    }

    @ApiOperation(value = "初始化-检查员-教学评估调查表")
    @GetMapping(value = "initJcyJxpgdcb")
    public HttpResult initJcyJxpgdcb(@RequestParam(value = "id",defaultValue = "")String id,
                                     @RequestParam(value = "flxjhid",defaultValue = "")String flxjhid){

        Map map = jcyLxpgdjbService.initJcyJxpgdcb(flxjhid, id);
        return HttpResult.ok(map);
    }

    @ApiOperation(value = "评估调查表-更新")
    @PostMapping(value = "updatePgDcb")
    public HttpResult updatePgDcb(@RequestBody SpcyJcyLxjxpgdcb buffer) throws InvocationTargetException, IllegalAccessException {

        jcyLxpgdjbService.updatePgDcb(buffer);
        return HttpResult.ok("保存成功");
    }

    @ApiOperation(value = "评估调查表-选项-更新")
    @PostMapping(value = "updatePgDcbXx")
    public HttpResult updatePgDcbXx(@RequestBody SpcyJcyLxjxpgxx buffer) throws InvocationTargetException, IllegalAccessException {

        jcyLxpgdjbService.updatePgDcbXx(buffer);
        return HttpResult.ok("保存成功");
    }

    @ApiOperation(value = "评估调查表-教师教学评价-更新")
    @PostMapping(value = "updateJsjxpj")
    public HttpResult updateJsjxpj(@RequestBody HashMap<String,String> buffer) throws InvocationTargetException, IllegalAccessException {

        jcyLxpgdjbService.updateJsjxpj(buffer);
        return HttpResult.ok("保存成功");
    }

    @ApiOperation(value = "评估调查表-提交")
    @GetMapping(value = "submitPgDcb")
    public HttpResult submitPgDcb(@RequestParam(value = "fpgdcbid",defaultValue = "")String fpgdcbid) throws InvocationTargetException, IllegalAccessException {

        jcyLxpgdjbService.submitPgDcb(fpgdcbid);
        return HttpResult.ok("保存成功");
    }

    @ApiOperation(value = "统计教学评估调查结果")
    @GetMapping(value = "tjJxpgDcJg")
    public HttpResult tjJxpgDcJg(@RequestParam(value = "flxjhid",defaultValue = "")String flxjhid){
        if (StringUtils.isBlank(flxjhid)){
            throw new BusinessException("参数为空！");
        }

        // 应参加评价人数
        JcyLxUserVo query = new JcyLxUserVo();
        query = spcyJcyLxService.ZhQueryTj(query, 1);
        query.setFlxjhid(flxjhid);

        Map resultMap = jcyLxpgdjbService.tjJxpgDcJg(flxjhid, query);
        return HttpResult.ok(resultMap);
    }
}
